<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>商品列表</title>
</head>
<body>
<div id="content">
    <h3 class="admin_link_bar">
        <jsp:include page="inc.jsp"/>
    </h3>
    <table style="margin-top:10px;" width="999" align="center" cellpadding="0" cellspacing="0" class="thin-border"
           border="1">
        <tr>
            <td colspan="6">
                <form action="/user/product/list">
                    请输入查询商品的名称：<input type="text" name="con" value="${con}"/><input type="submit" value="查询"/>
                </form>
            </td>
        </tr>
        <tr>
            <td>商品图片</td>
            <td>商品名称</td>
            <td>商品价格</td>
            <td>商品的库存</td>
            <td>商品状态</td>
            <td>操作</td>
        </tr>
        <c:forEach items="${products.datas }" var="p">
            <tr>
                <td><img src="<%=request.getContextPath()%>/resources/upload/${p.img}" width="130" height="130"/>
                </td>
                <td><a href="${p.id }/show">${p.name }</a>
                </td>
                <td>${p.price }
                </td>
                <td>${p.stock }
                    <shiro:hasPermission name="/admin/product">
                        <a href="${p.id }/add">添加</a>
                    </shiro:hasPermission>
                </td>
                <td>
                    <c:if test="${p.status eq 1 }">可购买</c:if>
                    <c:if test="${p.status eq -1 }"><span style="color:#832">已下架</span></c:if>
                    <shiro:hasPermission name="/admin/product">
                        <a href="${p.id }/updateStatus">变更</a>
                    </shiro:hasPermission>
                </td>
                <td>
                    <shiro:hasPermission name="/admin/product">
                        <a href="${p.id }/update">修改</a> <a
                            href="${p.id }/delete">删除</a>
                    </shiro:hasPermission>
                    <c:if test="${p.status eq 1 }"><a href="/user/order/${p.id}/add">加入购物车</a></c:if>
                    &nbsp;
                </td>
            </tr>
        </c:forEach>
        <tr>
            <td colspan="6">
                <jsp:include page="/jsp/pager.jsp">
                    <jsp:param value="list" name="url"/>
                    <jsp:param value="${products.totalPage }" name="items"/>
                    <jsp:param value="con" name="params"/>
                </jsp:include>
            </td>
        </tr>
    </table>
</div>
</body>
</html>